package com.market.utils;

import lombok.Data;

import java.util.List;

/**
 * 分页结果封装类
 */
@Data
public class PageResult<T> {
    // 当前页码
    private Integer currentPage;
    // 每页数量
    private Integer pageSize;
    // 总记录数
    private Long totalCount;
    // 总页数
    private Integer totalPages;
    // 数据列表
    private List<T> list;

    public PageResult() {
    }

    public PageResult(Integer currentPage, Integer pageSize, Long totalCount, List<T> list) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
        this.list = list;
        
        // 计算总页数
        this.totalPages = (int) Math.ceil((double) totalCount / pageSize);
    }
} 